package edu.sjb.thread;

import edu.sjb.AppLauncher;
import edu.sjb.map.LogicMapElement;

public class GravityThread extends Thread {
	public void run() {
		while (true) {
			for( int i = 0; i < 10; i++ )
			{
					
				double marioX2 = AppLauncher.GUI().mario().getPositionX();
				double marioY2 = AppLauncher.GUI().mario().getPositionY();
				int X2 = (int) Math.round(marioX2/32);
				int Y2 = (int) Math.round(marioY2/32);
				LogicMapElement belowMario = AppLauncher.GUI().map().getElementAt(X2,Y2+2).getLogicElement();	
				if (!belowMario.getName().equals("Brick"))
					{
						{
							try
							{
								AppLauncher.GUI().mario().setLocation(AppLauncher.GUI().mario().getLocation().x,
								AppLauncher.GUI().mario().getLocation().y + 32);
								Thread.sleep(25);
							} catch (Exception e)
							{
							e.printStackTrace();
							}
						}
					}
			}
		}
	
	}
}